<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>收货地址</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="__PUBLIC__/weixin/css/mui.css" />
		<link rel="stylesheet" href="__PUBLIC__/weixin/css/public.css" />
		<style type="text/css">
			.address-tit {
				padding-right: 8px;
			}
			
			.flex-item{
				color: #999;
			}
			
			.mui-table-view-cell:after {
				left: 0;
			}
			
			.mui-table-view-radio .mui-table-view-cell .mui-navigate-right:after {
				color: #3ab7cb;
			}
			/*.mui-table-view-cell.mui-selected{
				color: #fff;
				background-color: #5e6b85;
			}*/
			
			.new-address {
				background-color: #fff;
				padding: 10px 15px;
				height: 60px;
				line-height: 40px;
				text-align: center;
				border-bottom: 1px solid #c8c7cc;
				color: #3ab7cb;
			}
			
			.del{
				position: absolute;
				top: 0;
				right: 0;
				width: 30px;
				height: 30px;
				line-height: 30px;
				text-align: center;
				font-size: 16px;
			}
		</style>
	</head>

	<body>
		
		<div id="muiContent" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<ul class="mui-table-view mui-table-view-radio" id="addressList">
                                    <volist name="addressList" id="al">
                                        <li class="mui-table-view-cell" thisId="{$al.id}">  <!--  mui-selected  -->

						<a class="mui-navigate-right">
							<span class="del" thisId="{$al.id}">×</span>
							<div class="layout-box pb5">
								<span class="address-tit">收<ins class="half_words"></ins>货<ins class="half_words"></ins>人:</span>
								<span class="flex-item">{$al.consignee}</span>
							</div>
							<div class="layout-box pb5">
								<span class="address-tit">邮<ins class="two_words"></ins>编:</span>
								<span class="flex-item">{$al.zip}</span>
							</div>
							
							<div class="layout-box pb5">
								<span class="address-tit">联系电话:</span>
								<span class="flex-item">{$al.tel}</span>
							</div>
							<div class="layout-box">
								<span class="address-tit">收货地址:</span>
								<span class="flex-item line-break">{$al.address}</span>
							</div>
						</a>
                                    </li>
                                        
                                    </volist>
					
					
				</ul>
				<div id="noaddress" class="new-address">门店自提</div>
				<div id="address" class="new-address">+ 新增收货地址</div>
			</div>
		</div>
	</body>
        <script src="__PUBLIC__/js/jquery.min.js"></script>
	<script src="__PUBLIC__/weixin/js/mui.min.js"></script>
	<script>
		var type = '';
                var goods_id = "{$id}";
				var goods_spec_id = "{$goods_spec_id}";
		mui.init();
		
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});

		document.getElementById("address").addEventListener("tap", function() {
			window.location.href = "{:U('Weixin/Index/address_new')}"+"?id="+goods_id+"&goods_spec_id="+goods_spec_id;
		});
		document.getElementById("noaddress").addEventListener("tap", function() {
			window.location.href = "{:U('Weixin/Index/settlement')}"+"?id="+goods_id+"&address=-1&spec_id="+goods_spec_id;
		});
                
                mui("#addressList").on('tap','li',function(){
                    var thisId = this.getAttribute("thisId");
                    window.location.href = "{:U('Weixin/Index/settlement')}"+"?id="+goods_id+"&address="+thisId+"&spec_id="+goods_spec_id;
                })
                
                
                mui("#addressList").on('tap','.del',function(e){
					e.stopPropagation();
					
                    var thisId = this.getAttribute("thisId");
                    $.ajax({
                        url:"{:U('Weixin/Index/delAddress')}",
                        type:"post",
                        dataType:"json",
                        data:{ address_id : thisId},
                        success:function(data){
                            console.log(data);
                            window.location.reload();
                        }
                    })
                })
	</script>

</html>